import 'dart:math';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class WheelPainter extends CustomPainter {
  Paint getColorPaint(Color color) {
    Paint paint = Paint();
    paint.color = color;
    return paint;
  }

  @override
  void paint(Canvas canvas, Size size) {
    double wheelSize = min(size.width, size.height)/2;
    double numElem = 6;
    double radius = (2 * pi) / numElem;

    Rect boundingRect = Rect.fromCircle(center: Offset(wheelSize,wheelSize), radius: wheelSize);
    canvas.drawArc(boundingRect, 0, radius, true, getColorPaint(Colors.amber));
    canvas.drawArc(boundingRect, radius, radius, true, getColorPaint(Colors.red));
    canvas.drawArc(boundingRect, radius*2, radius, true, getColorPaint(Colors.green));
    canvas.drawArc(boundingRect, radius*3, radius, true, getColorPaint(Colors.blue));
    canvas.drawArc(boundingRect, radius*4, radius, true, getColorPaint(Colors.yellow));
    canvas.drawArc(boundingRect, radius*5, radius, true, getColorPaint(Colors.red));

  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return true;
  }
}

class Cake extends StatelessWidget {
  @override
  Widget build(BuildContext context) {

    return CustomPaint(
      size: Size(200,200),
      painter: WheelPainter(),
    );
  }
}